package main

import "fmt"

func trace(name string) func() {
	fmt.Println("enter:", name)
	return func() {
		fmt.Println("exit:", name)
	}
}

func foo() {
	defer trace("foo")()

	bar()
}

func bar() {
	defer trace("bar")()
}

func main() {
	fmt.Println("enter: main")

	foo()

	fmt.Println("exit: main")
}
